package com;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

public class ClientStartPoint 
{

    public static void main(String[] args) 
    {
    	Socket connection = null;
    	BufferedReader in, insys = null;
    	PrintWriter out = null;
    	String input, output;
    	
    	try {
    		System.out.println("Create socket");
			connection = new Socket("localhost", 58112);
			in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
			insys = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(connection.getOutputStream(),true);
    		System.out.println("Create Streams");
			while ((input = insys.readLine()) != null)
			{
	    		System.out.println("Strat circle");
				out.println(input);
				output = in.readLine();
				System.out.println(output);
				if (input.equalsIgnoreCase("close")) break;
				if (input.equalsIgnoreCase("exit")) break;
			}
			
			out.close();
			in.close();
			insys.close();
			connection.close();
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}        
   }
}